{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "DocProductPresentation.ipynb",
      "version": "0.3.2",
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Qaw6CoC4qUb5",
        "colab_type": "text"
      },
      "source": [
        "![DoctorBert](https://snag.gy/oF84Gk.jpg)\n",
        "\n",
        "\n",
        "![DoctorBert](https://i.ytimg.com/vi/nPemP-Q0Xn8/hqdefault.jpg)\n",
        "\n",
        "This is a Colab Demo of our DocProduct Tensorflow 2.0 Hackathon Project\n",
        "\n",
        "Project details can be seen on our Github repo\n",
        "https://github.com/Santosh-Gupta/DocProduct\n",
        "\n",
        "and our Devpost page\n",
        "https://devpost.com/software/nlp-doctor\n",
        "\n",
        "In order to fit the computational limits of Google Colab, we had to reduce the amount of searchable Q&A datapoints from ~700,000 to ~200,000.\n",
        "We also converted our search embeddings from float32 to float16, although this does not seem to dimish the quality of search (*but that's a whole other product to explore*)\n",
        "\n",
        "Instructions:\n",
        "\n",
        "-Run the first cell to install TF2.0 and FAISS\n",
        "\n",
        "-Run the second cell to download the models and data\n",
        "\n",
        "-Run the third cell to load the weights and data\n",
        "\n",
        "-Input your question and search parameters into the fourth cell to play around with our model results\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "jmMqTnR0kIBL",
        "colab_type": "code",
        "outputId": "8be1a29a-a1bb-4fef-a56b-f0d7bd2dfa1d",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 3063
        },
        "cellView": "form"
      },
      "source": [
        "#@title Install Faiss and TF 2.0. Double Click to see code\n",
        "\n",
        "#To use CPU FAISS use\n",
        "!wget  https://anaconda.org/pytorch/faiss-cpu/1.2.1/download/linux-64/faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2\n",
        "#To use GPU FAISS use\n",
        "# !wget  https://anaconda.org/pytorch/faiss-gpu/1.2.1/download/linux-64/faiss-gpu-1.2.1-py36_cuda9.0.176_1.tar.bz2\n",
        "!tar xvjf faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2\n",
        "!cp -r lib/python3.6/site-packages/* /usr/local/lib/python3.6/dist-packages/\n",
        "!pip install mkl\n",
        "\n",
        "!pip install tensorflow-gpu==2.0.0-alpha0\n",
        "import tensorflow as tf\n",
        "!pip install https://github.com/Santosh-Gupta/MedicalQA/archive/master.zip\n"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "--2019-05-07 04:58:12--  https://anaconda.org/pytorch/faiss-cpu/1.2.1/download/linux-64/faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2\n",
            "Resolving anaconda.org (anaconda.org)... 104.17.93.24, 104.17.92.24, 2606:4700::6811:5c18, ...\n",
            "Connecting to anaconda.org (anaconda.org)|104.17.93.24|:443... connected.\n",
            "HTTP request sent, awaiting response... 302 FOUND\n",
            "Location: https://binstar-cio-packages-prod.s3.amazonaws.com/5a15c9c5c376961204909d87/5aa7f0a65571b411e5c259be?response-content-disposition=attachment%3B%20filename%3D%22faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2%22%3B%20filename%2A%3DUTF-8%27%27faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2&response-content-type=application%2Fx-tar&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=60&X-Amz-Date=20190507T045812Z&X-Amz-SignedHeaders=host&X-Amz-Security-Token=AgoJb3JpZ2luX2VjECkaCXVzLWVhc3QtMSJIMEYCIQCfagVxzCK8GyvTXx%2FhZRF7JyuMHqXXOBPIKTOFjIfYVwIhANr3k0ef7DcbZonD8mOG%2FhgjQ2kQqkwyloVsJmtoJQOIKtoDCCEQABoMNDU1ODY0MDk4Mzc4IgyXqbz%2FfDxJFxIIDmQqtwNBrAtGbONKJsa7kLwkCqGMeULwz7PmHWz6KbvyjcWIvtA9pe%2F7qxceFHcCY3ihFIQjVCjDJzh%2Bb47kE0T8XIIoy2rhBge2jFxIjFNDHIgDZvf95iqxJz7Z4zXaH6CVruGJfqvhpFBD2Ya4uc8SPhCifmH6wip88GEh9WExYooWstV5ubMuLnFSFh6bnzQPAgEDtMesgXc30%2FPhYCaaVWsr825Zlg1KLd0CrcTsGZ%2FDaRY88S0xcGw9q%2BOrl8zzDBdXRwYcJmpiTyXh4YIlZBvv51eZFOD6an%2F5VVBCGIuFp1ACNzwOqTrubLj2mV4HHlyKmv%2FaFELAmIXcyoddaGDY8VIl3eWTyCDLXdUstbHpAEHrTRFyJcPp3RzR2FUKLGoVoR%2FQbcmb5ZriLM90f31BVcYGrWSiYFgu8bNd0fRu4ubamkqBiXRwbQbxiCNJAwV7YAGjMa9LcRgRyxIi9yeG78hj%2FeevIQb4BB6cHjP2%2F8cneHP5mf5NrF2GqQ%2BUpOh%2BxFcXGFUB99jaGCizqryEJEaveIxG8bt3d0V2Cqc4VQ%2FreNOLmJLprVLL5fqhX4k9A9CB92m%2FMMqew%2BYFOrMBPYVIm4i8ilZeA8zyiUDR7UrBv7x%2B5cDp1VQ%2Bjuz9Vfnv0%2Bel1uiBd4PLJcFzWmSzTpGzNPE6AK6NsCIwiku%2F%2Fzrp%2FHxQcILDksK47YVikz%2BE7sSjhpmhRmUj4wAdmNmOzj4JEzlTWqCaCfYdhV50PBh2Q4pThp%2BKgzjz%2FMUAtBCMmWCvVWMHbtKwUnwFaNWsip%2BbR6XjuNIySdzahtp1gn%2BMStM5oMjM7KiQNKhr2K8GJiM%3D&X-Amz-Credential=ASIAWUI46DZFF3BHSJXE%2F20190507%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=20fa73e96528138cdcf952d808f648ee4c8d4c25cce0b20b9baec56eb31ca0d1 [following]\n",
            "--2019-05-07 04:58:12--  https://binstar-cio-packages-prod.s3.amazonaws.com/5a15c9c5c376961204909d87/5aa7f0a65571b411e5c259be?response-content-disposition=attachment%3B%20filename%3D%22faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2%22%3B%20filename%2A%3DUTF-8%27%27faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2&response-content-type=application%2Fx-tar&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=60&X-Amz-Date=20190507T045812Z&X-Amz-SignedHeaders=host&X-Amz-Security-Token=AgoJb3JpZ2luX2VjECkaCXVzLWVhc3QtMSJIMEYCIQCfagVxzCK8GyvTXx%2FhZRF7JyuMHqXXOBPIKTOFjIfYVwIhANr3k0ef7DcbZonD8mOG%2FhgjQ2kQqkwyloVsJmtoJQOIKtoDCCEQABoMNDU1ODY0MDk4Mzc4IgyXqbz%2FfDxJFxIIDmQqtwNBrAtGbONKJsa7kLwkCqGMeULwz7PmHWz6KbvyjcWIvtA9pe%2F7qxceFHcCY3ihFIQjVCjDJzh%2Bb47kE0T8XIIoy2rhBge2jFxIjFNDHIgDZvf95iqxJz7Z4zXaH6CVruGJfqvhpFBD2Ya4uc8SPhCifmH6wip88GEh9WExYooWstV5ubMuLnFSFh6bnzQPAgEDtMesgXc30%2FPhYCaaVWsr825Zlg1KLd0CrcTsGZ%2FDaRY88S0xcGw9q%2BOrl8zzDBdXRwYcJmpiTyXh4YIlZBvv51eZFOD6an%2F5VVBCGIuFp1ACNzwOqTrubLj2mV4HHlyKmv%2FaFELAmIXcyoddaGDY8VIl3eWTyCDLXdUstbHpAEHrTRFyJcPp3RzR2FUKLGoVoR%2FQbcmb5ZriLM90f31BVcYGrWSiYFgu8bNd0fRu4ubamkqBiXRwbQbxiCNJAwV7YAGjMa9LcRgRyxIi9yeG78hj%2FeevIQb4BB6cHjP2%2F8cneHP5mf5NrF2GqQ%2BUpOh%2BxFcXGFUB99jaGCizqryEJEaveIxG8bt3d0V2Cqc4VQ%2FreNOLmJLprVLL5fqhX4k9A9CB92m%2FMMqew%2BYFOrMBPYVIm4i8ilZeA8zyiUDR7UrBv7x%2B5cDp1VQ%2Bjuz9Vfnv0%2Bel1uiBd4PLJcFzWmSzTpGzNPE6AK6NsCIwiku%2F%2Fzrp%2FHxQcILDksK47YVikz%2BE7sSjhpmhRmUj4wAdmNmOzj4JEzlTWqCaCfYdhV50PBh2Q4pThp%2BKgzjz%2FMUAtBCMmWCvVWMHbtKwUnwFaNWsip%2BbR6XjuNIySdzahtp1gn%2BMStM5oMjM7KiQNKhr2K8GJiM%3D&X-Amz-Credential=ASIAWUI46DZFF3BHSJXE%2F20190507%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=20fa73e96528138cdcf952d808f648ee4c8d4c25cce0b20b9baec56eb31ca0d1\n",
            "Resolving binstar-cio-packages-prod.s3.amazonaws.com (binstar-cio-packages-prod.s3.amazonaws.com)... 52.216.170.179\n",
            "Connecting to binstar-cio-packages-prod.s3.amazonaws.com (binstar-cio-packages-prod.s3.amazonaws.com)|52.216.170.179|:443... connected.\n",
            "HTTP request sent, awaiting response... 200 OK\n",
            "Length: 4106816 (3.9M) [application/x-tar]\n",
            "Saving to: ‘faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2’\n",
            "\n",
            "faiss-cpu-1.2.1-py3 100%[===================>]   3.92M  16.8MB/s    in 0.2s    \n",
            "\n",
            "2019-05-07 04:58:13 (16.8 MB/s) - ‘faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2’ saved [4106816/4106816]\n",
            "\n",
            "info/hash_input.json\n",
            "info/has_prefix\n",
            "info/index.json\n",
            "info/git\n",
            "info/files\n",
            "info/LICENSE.txt\n",
            "info/about.json\n",
            "info/paths.json\n",
            "lib/python3.6/site-packages/faiss-0.1-py3.6.egg-info/dependency_links.txt\n",
            "lib/python3.6/site-packages/faiss-0.1-py3.6.egg-info/not-zip-safe\n",
            "lib/python3.6/site-packages/faiss-0.1-py3.6.egg-info/requires.txt\n",
            "lib/python3.6/site-packages/faiss-0.1-py3.6.egg-info/top_level.txt\n",
            "lib/python3.6/site-packages/faiss-0.1-py3.6.egg-info/native_libs.txt\n",
            "info/test/run_test.py\n",
            "info/test/run_test.sh\n",
            "info/test/tests/run_tests.sh\n",
            "lib/python3.6/site-packages/faiss-0.1-py3.6.egg-info/SOURCES.txt\n",
            "info/recipe/conda_build_config.yaml\n",
            "info/recipe/build.sh\n",
            "info/test/tests/CMakeLists.txt\n",
            "info/test/tests/Makefile\n",
            "info/recipe/meta.yaml.template\n",
            "lib/python3.6/site-packages/faiss-0.1-py3.6.egg-info/PKG-INFO\n",
            "info/test/tests/test_factory.py\n",
            "info/test/tests/test_ivfpq_codec.cpp\n",
            "info/recipe/meta.yaml\n",
            "info/recipe/setup.py\n",
            "info/test/tests/test_blas.cpp\n",
            "info/recipe/makefile.inc\n",
            "info/test/tests/test_ivfpq_indexing.cpp\n",
            "info/test/tests/test_ondisk_ivf.cpp\n",
            "info/test/tests/test_build_blocks.py\n",
            "info/test/tests/test_merge.cpp\n",
            "info/test/tests/test_pairs_decoding.cpp\n",
            "info/test/tests/test_index_composite.py\n",
            "lib/python3.6/site-packages/faiss/__init__.py\n",
            "lib/python3.6/site-packages/faiss/__pycache__/__init__.cpython-36.pyc\n",
            "info/test/tests/test_index.py\n",
            "info/test/tests/test_blas\n",
            "lib/python3.6/site-packages/faiss/__pycache__/swigfaiss.cpython-36.pyc\n",
            "lib/python3.6/site-packages/faiss/swigfaiss.py\n",
            "lib/python3.6/site-packages/faiss/_swigfaiss.so\n",
            "Requirement already satisfied: mkl in /usr/local/lib/python3.6/dist-packages (2019.0)\n",
            "Requirement already satisfied: intel-openmp in /usr/local/lib/python3.6/dist-packages (from mkl) (2019.0)\n",
            "Collecting tensorflow-gpu==2.0.0-alpha0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/1a/66/32cffad095253219d53f6b6c2a436637bbe45ac4e7be0244557210dc3918/tensorflow_gpu-2.0.0a0-cp36-cp36m-manylinux1_x86_64.whl (332.1MB)\n",
            "\u001b[K     |████████████████████████████████| 332.1MB 55kB/s \n",
            "\u001b[?25hRequirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==2.0.0-alpha0) (1.12.0)\n",
            "Collecting google-pasta>=0.1.2 (from tensorflow-gpu==2.0.0-alpha0)\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/64/bb/f1bbc131d6294baa6085a222d29abadd012696b73dcbf8cf1bf56b9f082a/google_pasta-0.1.5-py3-none-any.whl (51kB)\n",
            "\u001b[K     |████████████████████████████████| 61kB 31.2MB/s \n",
            "\u001b[?25hRequirement already satisfied: numpy<2.0,>=1.14.5 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==2.0.0-alpha0) (1.16.3)\n",
            "Collecting tb-nightly<1.14.0a20190302,>=1.14.0a20190301 (from tensorflow-gpu==2.0.0-alpha0)\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/a9/51/aa1d756644bf4624c03844115e4ac4058eff77acd786b26315f051a4b195/tb_nightly-1.14.0a20190301-py3-none-any.whl (3.0MB)\n",
            "\u001b[K     |████████████████████████████████| 3.0MB 39.5MB/s \n",
            "\u001b[?25hRequirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==2.0.0-alpha0) (1.1.0)\n",
            "Requirement already satisfied: wheel>=0.26 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==2.0.0-alpha0) (0.33.1)\n",
            "Requirement already satisfied: keras-applications>=1.0.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==2.0.0-alpha0) (1.0.7)\n",
            "Requirement already satisfied: protobuf>=3.6.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==2.0.0-alpha0) (3.7.1)\n",
            "Collecting tf-estimator-nightly<1.14.0.dev2019030116,>=1.14.0.dev2019030115 (from tensorflow-gpu==2.0.0-alpha0)\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/13/82/f16063b4eed210dc2ab057930ac1da4fbe1e91b7b051a6c8370b401e6ae7/tf_estimator_nightly-1.14.0.dev2019030115-py2.py3-none-any.whl (411kB)\n",
            "\u001b[K     |████████████████████████████████| 419kB 57.2MB/s \n",
            "\u001b[?25hRequirement already satisfied: astor>=0.6.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==2.0.0-alpha0) (0.7.1)\n",
            "Requirement already satisfied: absl-py>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==2.0.0-alpha0) (0.7.1)\n",
            "Requirement already satisfied: gast>=0.2.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==2.0.0-alpha0) (0.2.2)\n",
            "Requirement already satisfied: grpcio>=1.8.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==2.0.0-alpha0) (1.15.0)\n",
            "Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.6/dist-packages (from tensorflow-gpu==2.0.0-alpha0) (1.0.9)\n",
            "Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.6/dist-packages (from tb-nightly<1.14.0a20190302,>=1.14.0a20190301->tensorflow-gpu==2.0.0-alpha0) (3.1)\n",
            "Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.6/dist-packages (from tb-nightly<1.14.0a20190302,>=1.14.0a20190301->tensorflow-gpu==2.0.0-alpha0) (0.15.2)\n",
            "Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from keras-applications>=1.0.6->tensorflow-gpu==2.0.0-alpha0) (2.8.0)\n",
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from protobuf>=3.6.1->tensorflow-gpu==2.0.0-alpha0) (41.0.1)\n",
            "Installing collected packages: google-pasta, tb-nightly, tf-estimator-nightly, tensorflow-gpu\n",
            "Successfully installed google-pasta-0.1.5 tb-nightly-1.14.0a20190301 tensorflow-gpu-2.0.0a0 tf-estimator-nightly-1.14.0.dev2019030115\n",
            "Collecting https://github.com/Santosh-Gupta/MedicalQA/archive/master.zip\n",
            "\u001b[?25l  Downloading https://github.com/Santosh-Gupta/MedicalQA/archive/master.zip\n",
            "\u001b[K     / 23.4MB 190kB/s\n",
            "\u001b[?25hRequirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from MedicalQA==0.1.0) (1.16.3)\n",
            "Requirement already satisfied: matplotlib in /usr/local/lib/python3.6/dist-packages (from MedicalQA==0.1.0) (3.0.3)\n",
            "Collecting tensorflow==2.0.0-alpha0 (from MedicalQA==0.1.0)\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/29/39/f99185d39131b8333afcfe1dcdb0629c2ffc4ecfb0e4c14ca210d620e56c/tensorflow-2.0.0a0-cp36-cp36m-manylinux1_x86_64.whl (79.9MB)\n",
            "\u001b[K     |████████████████████████████████| 79.9MB 51.9MB/s \n",
            "\u001b[?25hRequirement already satisfied: tensorflow-gpu==2.0.0-alpha0 in /usr/local/lib/python3.6/dist-packages (from MedicalQA==0.1.0) (2.0.0a0)\n",
            "Requirement already satisfied: Keras in /usr/local/lib/python3.6/dist-packages (from MedicalQA==0.1.0) (2.2.4)\n",
            "Collecting keras-pos-embd==0.9.0 (from MedicalQA==0.1.0)\n",
            "  Downloading https://files.pythonhosted.org/packages/56/5e/7b1e933104a25f2039b6788e392a650671e3bcbee6404ea29dcb92295614/keras-pos-embd-0.9.0.tar.gz\n",
            "Collecting keras-transformer==0.21.0 (from MedicalQA==0.1.0)\n",
            "  Downloading https://files.pythonhosted.org/packages/d3/3a/ad25f5c71adc6b8aa73f71b1367be873b4103125a614ba57c006d1a9b1ff/keras-transformer-0.21.0.tar.gz\n",
            "Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from MedicalQA==0.1.0) (4.28.1)\n",
            "Requirement already satisfied: faiss in /usr/local/lib/python3.6/dist-packages (from MedicalQA==0.1.0) (0.1)\n",
            "Requirement already satisfied: sklearn in /usr/local/lib/python3.6/dist-packages (from MedicalQA==0.1.0) (0.0)\n",
            "Collecting pycurl (from MedicalQA==0.1.0)\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/e8/e4/0dbb8735407189f00b33d84122b9be52c790c7c3b25286826f4e1bdb7bde/pycurl-7.43.0.2.tar.gz (214kB)\n",
            "\u001b[K     |████████████████████████████████| 215kB 49.4MB/s \n",
            "\u001b[?25hRequirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from MedicalQA==0.1.0) (1.12.0)\n",
            "Collecting argparse (from MedicalQA==0.1.0)\n",
            "  Downloading https://files.pythonhosted.org/packages/f2/94/3af39d34be01a24a6e65433d19e107099374224905f1e0cc6bbe1fd22a2f/argparse-1.4.0-py2.py3-none-any.whl\n",
            "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->MedicalQA==0.1.0) (1.1.0)\n",
            "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib->MedicalQA==0.1.0) (0.10.0)\n",
            "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->MedicalQA==0.1.0) (2.4.0)\n",
            "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->MedicalQA==0.1.0) (2.5.3)\n",
            "Requirement already satisfied: gast>=0.2.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (0.2.2)\n",
            "Requirement already satisfied: protobuf>=3.6.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (3.7.1)\n",
            "Requirement already satisfied: absl-py>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (0.7.1)\n",
            "Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (1.1.0)\n",
            "Requirement already satisfied: tb-nightly<1.14.0a20190302,>=1.14.0a20190301 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (1.14.0a20190301)\n",
            "Requirement already satisfied: wheel>=0.26 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (0.33.1)\n",
            "Requirement already satisfied: keras-applications>=1.0.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (1.0.7)\n",
            "Requirement already satisfied: grpcio>=1.8.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (1.15.0)\n",
            "Requirement already satisfied: tf-estimator-nightly<1.14.0.dev2019030116,>=1.14.0.dev2019030115 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (1.14.0.dev2019030115)\n",
            "Requirement already satisfied: astor>=0.6.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (0.7.1)\n",
            "Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (1.0.9)\n",
            "Requirement already satisfied: google-pasta>=0.1.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (0.1.5)\n",
            "Requirement already satisfied: scipy>=0.14 in /usr/local/lib/python3.6/dist-packages (from Keras->MedicalQA==0.1.0) (1.2.1)\n",
            "Requirement already satisfied: pyyaml in /usr/local/lib/python3.6/dist-packages (from Keras->MedicalQA==0.1.0) (3.13)\n",
            "Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from Keras->MedicalQA==0.1.0) (2.8.0)\n",
            "Collecting keras-multi-head==0.18.0 (from keras-transformer==0.21.0->MedicalQA==0.1.0)\n",
            "  Downloading https://files.pythonhosted.org/packages/d7/5d/8156def9ca75c55bb87819618e9a3e1f8e587c722570e2e93ad616b9269d/keras-multi-head-0.18.0.tar.gz\n",
            "Collecting keras-layer-normalization==0.11.0 (from keras-transformer==0.21.0->MedicalQA==0.1.0)\n",
            "  Downloading https://files.pythonhosted.org/packages/c6/b0/c786d5a5e79d985281a06da0a1f3f559cf425921464e6b07b9f1cb093a5a/keras-layer-normalization-0.11.0.tar.gz\n",
            "Collecting keras-position-wise-feed-forward==0.4.0 (from keras-transformer==0.21.0->MedicalQA==0.1.0)\n",
            "  Downloading https://files.pythonhosted.org/packages/91/21/4eefba0b6ea01de9c6e469970a39dbdbce14e5183a20274d9a181f55eaa8/keras-position-wise-feed-forward-0.4.0.tar.gz\n",
            "Collecting keras-embed-sim==0.3.0 (from keras-transformer==0.21.0->MedicalQA==0.1.0)\n",
            "  Downloading https://files.pythonhosted.org/packages/8e/16/b05954f9578ded225fd1bd56154ade949782c03b668a1fc424d5050e868a/keras-embed-sim-0.3.0.tar.gz\n",
            "Requirement already satisfied: scikit-learn in /usr/local/lib/python3.6/dist-packages (from sklearn->MedicalQA==0.1.0) (0.20.3)\n",
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from kiwisolver>=1.0.1->matplotlib->MedicalQA==0.1.0) (41.0.1)\n",
            "Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.6/dist-packages (from tb-nightly<1.14.0a20190302,>=1.14.0a20190301->tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (3.1)\n",
            "Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.6/dist-packages (from tb-nightly<1.14.0a20190302,>=1.14.0a20190301->tensorflow==2.0.0-alpha0->MedicalQA==0.1.0) (0.15.2)\n",
            "Collecting keras-self-attention==0.39.0 (from keras-multi-head==0.18.0->keras-transformer==0.21.0->MedicalQA==0.1.0)\n",
            "  Downloading https://files.pythonhosted.org/packages/91/70/51150779d5bbd1488a30c62026b141073873faf81eac7a62c6460cb5efe0/keras-self-attention-0.39.0.tar.gz\n",
            "Building wheels for collected packages: MedicalQA, keras-pos-embd, keras-transformer, pycurl, keras-multi-head, keras-layer-normalization, keras-position-wise-feed-forward, keras-embed-sim, keras-self-attention\n",
            "  Building wheel for MedicalQA (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Stored in directory: /tmp/pip-ephem-wheel-cache-hu6n2_2o/wheels/ae/dd/52/4a9dbde8157814168f13e8a772aaea83e578bd74a6834d1d86\n",
            "  Building wheel for keras-pos-embd (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Stored in directory: /root/.cache/pip/wheels/fb/97/65/170068ed0a4bd2185d561afee6c93e23e87e8d735d61389590\n",
            "  Building wheel for keras-transformer (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Stored in directory: /root/.cache/pip/wheels/19/9f/ff/3b38f44f6db035cfd33cff4909edcc4864a6aeec80d9deaf23\n",
            "  Building wheel for pycurl (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Stored in directory: /root/.cache/pip/wheels/d2/85/ae/ebf5ff0f1368869d082b4863df492bf54c661bf6306a2bdfde\n",
            "  Building wheel for keras-multi-head (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Stored in directory: /root/.cache/pip/wheels/9f/88/83/d7680876b48974c3c11fc334ed1d0a480ae218764062385bf3\n",
            "  Building wheel for keras-layer-normalization (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Stored in directory: /root/.cache/pip/wheels/86/dc/2e/3ac54a6b948bff68cb999d210c6ebf9e22df7a4a24cf114436\n",
            "  Building wheel for keras-position-wise-feed-forward (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Stored in directory: /root/.cache/pip/wheels/40/a1/13/3c913efde102d56ac584f61004a9fec6f8859b6feec6aa7aa7\n",
            "  Building wheel for keras-embed-sim (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Stored in directory: /root/.cache/pip/wheels/bf/f2/c6/0610efe9730c708b24ec29c25cebd38eb485acbc2eee7b5634\n",
            "  Building wheel for keras-self-attention (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Stored in directory: /root/.cache/pip/wheels/6c/d6/3e/cac34bf035198e38947006910f3ecb25613d6d9d76ea6d8ef2\n",
            "Successfully built MedicalQA keras-pos-embd keras-transformer pycurl keras-multi-head keras-layer-normalization keras-position-wise-feed-forward keras-embed-sim keras-self-attention\n",
            "Installing collected packages: tensorflow, keras-pos-embd, keras-self-attention, keras-multi-head, keras-layer-normalization, keras-position-wise-feed-forward, keras-embed-sim, keras-transformer, pycurl, argparse, MedicalQA\n",
            "  Found existing installation: tensorflow 1.13.1\n",
            "    Uninstalling tensorflow-1.13.1:\n",
            "      Successfully uninstalled tensorflow-1.13.1\n",
            "Successfully installed MedicalQA-0.1.0 argparse-1.4.0 keras-embed-sim-0.3.0 keras-layer-normalization-0.11.0 keras-multi-head-0.18.0 keras-pos-embd-0.9.0 keras-position-wise-feed-forward-0.4.0 keras-self-attention-0.39.0 keras-transformer-0.21.0 pycurl-7.43.0.2 tensorflow-2.0.0a0\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.colab-display-data+json": {
              "pip_warning": {
                "packages": [
                  "argparse",
                  "tensorflow"
                ]
              }
            }
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "2WSlwhdFC_0K",
        "colab_type": "code",
        "colab": {},
        "cellView": "form"
      },
      "source": [
        "#@title Downaload all model checkpoints, and question/answer data. Double click to see this code\n",
        "\n",
        "def download_file_from_google_drive(id, destination):\n",
        "    URL = \"https://docs.google.com/uc?export=download\"\n",
        "\n",
        "    session = requests.Session()\n",
        "\n",
        "    response = session.get(URL, params = { 'id' : id }, stream = True)\n",
        "    token = get_confirm_token(response)\n",
        "\n",
        "    if token:\n",
        "        params = { 'id' : id, 'confirm' : token }\n",
        "        response = session.get(URL, params = params, stream = True)\n",
        "\n",
        "    save_response_content(response, destination)    \n",
        "\n",
        "def get_confirm_token(response):\n",
        "    for key, value in response.cookies.items():\n",
        "        if key.startswith('download_warning'):\n",
        "            return value\n",
        "\n",
        "    return None\n",
        "\n",
        "def save_response_content(response, destination):\n",
        "    CHUNK_SIZE = 32768\n",
        "\n",
        "    with open(destination, \"wb\") as f:\n",
        "        for chunk in response.iter_content(CHUNK_SIZE):\n",
        "            if chunk: # filter out keep-alive new chunks\n",
        "                f.write(chunk)\n",
        "                \n",
        "import os\n",
        "\n",
        "if not os.path.exists('models'):\n",
        "    os.mkdir('models')\n",
        "    \n",
        "if not os.path.exists('models/bertffn_crossentropy'):\n",
        "    os.mkdir('models/bertffn_crossentropy')\n",
        "    \n",
        "if not os.path.exists('models/bertffn_crossentropy/bertffn'):\n",
        "    os.mkdir('models/bertffn_crossentropy/bertffn')\n",
        "    \n",
        "import requests\n",
        "\n",
        "if not os.path.exists('qa_embeddings'):\n",
        "    os.mkdir('qa_embeddings')\n",
        "    \n",
        "if not os.path.exists('chkpoint'):\n",
        "    os.mkdir('chkpoint')\n",
        "    \n",
        "file_id = '1thX75_cMkly5btgxTydgV6YDKnrUczZs'\n",
        "\n",
        "download_file_from_google_drive(file_id, 'models/bertffn_crossentropy/bertffn/bertffn.data-00000-of-00001')\n",
        "\n",
        "file_id = '11q29T38EysVPueD1PMQzZoKs5QFr3jRT'\n",
        "\n",
        "download_file_from_google_drive(file_id, 'models/bertffn_crossentropy/bertffn/bertffn.index')\n",
        "\n",
        "file_id = '1iI5Aow_7pQSmvpxGnMVKw9OJV-nckkxz'\n",
        "\n",
        "download_file_from_google_drive(file_id, 'models/bertffn_crossentropy/bertffn/bertffn.checkpoint')\n",
        "\n",
        "os.listdir('models/bertffn_crossentropy/bertffn')\n",
        "\n",
        "import urllib.request\n",
        "...\n",
        "# Download the file from `url` and save it locally under `file_name`:\n",
        "urllib.request.urlretrieve('https://github.com/naver/biobert-pretrained/releases/download/v1.0-pubmed-pmc/biobert_pubmed_pmc.tar.gz', 'BioBert.tar.gz')\n",
        "\n",
        "if not os.path.exists('BioBertFolder'):\n",
        "    os.makedirs('BioBertFolder')\n",
        "    \n",
        "import tarfile\n",
        "tar = tarfile.open(\"BioBert.tar.gz\")\n",
        "tar.extractall(path='BioBertFolder/')\n",
        "tar.close()\n",
        "\n",
        "os.listdir('BioBertFolder/pubmed_pmc_470k')\n",
        "\n",
        "if not os.path.exists('FFNNFolder'):\n",
        "    os.makedirs('FFNNFolder')\n",
        "    \n",
        "file_id = '1-258Wlpp5UwwqCPezy6DRYBozO4wBUBw'\n",
        "\n",
        "download_file_from_google_drive(file_id, 'FFNNFolder/data-00000-of-00001')\n",
        "\n",
        "file_id = '1-9JmtJJ_XGV0wClZxs2Px4hDL-Pi9YA_'\n",
        "\n",
        "download_file_from_google_drive(file_id, 'FFNNFolder/index')\n",
        "\n",
        "file_id = '1-5hczUjQfCTpBg1HhpLrgXFTkve1xuRM'\n",
        "\n",
        "download_file_from_google_drive(file_id, 'FFNNFolder/checkpoint')\n",
        "\n",
        "#download data\n",
        "\n",
        "# file_id = '1blkZdV1BNWesD0mJ6Pm1H1IhCMYThkWJ'\n",
        "\n",
        "# download_file_from_google_drive(file_id, 'Float16Embeddings.pkl')\n",
        "\n",
        "file_id = '1jnRRljMv752su76j6aLWIyHD5oo6itMN'\n",
        "\n",
        "download_file_from_google_drive(file_id, 'Float16EmbeddingsExpanded.pkl')"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ztuTHeW4jFiH",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "cellView": "form",
        "outputId": "0b0ae6e1-531d-46a2-c6e0-784adb08691e"
      },
      "source": [
        "#@title Load model weights and Q&A data. Double click to see code\n",
        "\n",
        "from docproduct.predictor import RetreiveQADoc\n",
        "\n",
        "pretrained_path = 'BioBertFolder/pubmed_pmc_470k/'\n",
        "ffn_weight_file = None\n",
        "bert_ffn_weight_file = 'models/bertffn_crossentropy/bertffn/bertffn'\n",
        "embedding_file = 'Float16EmbeddingsExpanded.pkl'\n",
        "\n",
        "doc = RetreiveQADoc(pretrained_path=pretrained_path,\n",
        "ffn_weight_file=None,\n",
        "bert_ffn_weight_file=bert_ffn_weight_file,\n",
        "embedding_file=embedding_file)"
      ],
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Failed to load GPU Faiss: No module named 'faiss.swigfaiss_gpu'\n",
            "Faiss falling back to CPU-only.\n"
          ],
          "name": "stderr"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qZ110ZqNfBac",
        "colab_type": "code",
        "outputId": "b2711e36-2a48-478d-aedb-f6ce167cf289",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1298
        },
        "cellView": "form"
      },
      "source": [
        "#@title Type in your question (512 word limit) and search search parameters\n",
        "\n",
        "question_text = \"Hey Dr's and Medical Professionals of Reddit. I'm in need of some assistance regarding my tonsillitis. I'm 19 turning 20 of Hispanic ethnicity,5'1 and 170 lbs. About two days ago I started getting a sore throat and I've had my fair share of sore throats so I wasn't too concerned well yesterday I woke up with severely enlarged tonsils so I started my salt gargles like any person would do, well that didn't work and my tonsils continued to become swollen to the point that my voice has become muffled and I can't pronounce any \\\"ey\\\" sounding words without sounding like a fucking idiot. Anyway, at around 6am today I got my ass to the ER and got aN attending physician he gave me a prescription of Amoxicillin 500mg and sent me on my way. Well because I slept the entire day after being kept up with my tonsil pain shit went from bad to mother fucking worse. At around 7:00PM today I felt like I had some phlegm stuck in my throat so I went to the bathroom to cough it up and it was a bloodclot. As soon as that bloodclot came out I started coughing up more of it before it subsided a lil. I started to do some salt gargles again and that \\\"suprisingly\\\" didn't work and about 10 minutes ago I coughed up about 1/3 cup of blood and as I'm writing this coughed up some more. Please help me lol.\"  #@param {type:\"string\"}\n",
        "\n",
        "search_similarity_by = 'answer'  #@param ['answer', \"question\"]\n",
        "\n",
        "number_results_toReturn=10 #@param {type:\"number\"}\n",
        "\n",
        "answer_only=True #@param [\"False\", \"True\"] {type:\"raw\"}\n",
        "\n",
        "returned_results = doc.predict( question_text ,\n",
        "                  search_by=search_similarity_by, topk=number_results_toReturn, answer_only=search_similarity_by)\n",
        "\n",
        "print('')\n",
        "for jk in range(len(returned_results)):\n",
        "    print(\"Result \", jk+1)\n",
        "    print(returned_results[jk])\n",
        "    print('')\n"
      ],
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "1it [00:00,  4.50it/s]"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "\n",
            "Result  1\n",
            "Complete full course of Abx and if still having problems see ENT. If fever go to ED. ,How are you doing? \n",
            "\n",
            "Result  2\n",
            "How long did the physician prescribe the amoxicillin? Did he or she do a strep test or diagnose it based on symtpoms? How long were you symptomatic beforehand?,Just take your antibiotics as directed and it should clear up. If it hasn't improved at all by the end of the course, or if you significantly worsen over the next several days, contact your doctor.\n",
            "\n",
            "Result  3\n",
            "It could very well be an abscess and urgent care won’t touch it. Go to an ER or an ENT.,Can you take a picture?\n",
            ",Amoxicillin is not ototoxic, but if one tonsil is \"way bigger,\" you need to make sure it goes down. I would go ahead and book an ENT appointment. If it goes back down to normal, then cancel it. But if it doesn't, get their opinion.\n",
            "\n",
            "Result  4\n",
            "You should see a doctor if you think you have tonsillitis\n",
            "\n",
            "There's not much point in only taking a single dose of Amoxicillin.  You need 10 days of antibiotics to properly treat tonsillitis.  A single dose isn't going to fix the problem and might cause bacterial resistance.,I'm sorry about your situation.  \n",
            "\n",
            "It doesn't change what the advice would be for suspected tonsillitis.  The answer for pretty much every problem on here is going to be that you should see a doctor.\n",
            "\n",
            "Not all cases of tonsillitis need antibiotics, as many are caused by viruses.  But you need a doctor to examine you to determine that.\n",
            "\n",
            "People with tonsillitis are usually recommended to drink lots of fluids,use pain medications like acetaminophen for pain and fever, use throat lozenges for relief.\n",
            "\n",
            "Mild cases of tonsillitis in healthy people may get better on their own.\n",
            "\n",
            "But more severe cases of tonsillitis, especially those infected with Strep, may go on to develop more rare but serious consequences such as throat abscesses which may compromise breathing, cause rheumatic fever and heart damage, cause kidney damage, etc.\n",
            "\n",
            "If you can't afford a physician, I understand that some emergency departments in the US are required to offer you medical treatment for acute conditions regardless of ability to pay.\n",
            "\n",
            "Result  5\n",
            "No, these just look like badly swollen tonsils, which is pretty common for mono/glandular fever.\n",
            "\n",
            "Also, this isn't an amoxicillin allergy. Getting a rash from taking antibiotics while having EBV is [common (search \"amoxicillin\")](http://www.aafp.org/afp/2004/1001/p1279.html) and not indicative of a true allergy.\n",
            "\n",
            "/u/Captain_Ruke Make sure you're treating the symptoms - Tylenol (paracetamol since you're in the UK) or Ibuprofen can really help. There isn't much else in the way of treatment that's actually been shown to help, unfortunately.\n",
            "\n",
            "Result  6\n",
            "Even though that's the common appearance of streptococcal pharyngitis, some other viruses can cause that appearance, for example mononucleosis (Epstein Bar virus). Which doesn't require any specialized treatment. Since you started antibiotic therapy you should finish it as prescribed. ,This is bad advice. \n",
            "\n",
            "Just continue your antibiotics course. ,If you can't swallow, have trouble breathing or if the pain is unbearable. You may need steroids to help shrink the tonsils. ,When tonsils get swollen it takes some time for all the inflammation (either because of viral or bacterial cause) to resolve and to return to their normal size. Tonsils getting very big is mostly a problem in children, not someone of your age; most probably they will go down since I assume you don't have any other disease. Antibiotics are to kill the bacteria, but the inflammatory process will still be there even though the virus or bacteria is gone for a while. Just for some reason you develop high strong persistent fevers, or a new different strong pain (not the swallowing one) just tell me and I'll tell you if it's needed to see the doctor. Most probably you won't need it, just wait until your tonsils finish their immune work. Pharyngitis most of the time are self resolving but are a pain in the ass. It will take a week approximately for it to go away. ,What? The ACA *is* Obamacare???!,What you're describing would help with tonsil stones, if you can keep your gag reflex down, but OP has no tonsil stones.,You're welcome! Those progression pics are beautiful, I'll save them for later if you don't mind :)\n",
            "To add: as other stated if pain is unbearable you may benefit from steroid therapy. I wouldn't recommend doing great since it hurts you, just wait it out with aspirin or naproxen or any other painmed.,Just because the rapid strep is negative doesn't necessarily rule it out. Conventional kids are ~65-~95% accurate with perfect use - so there is a user error component in there. That said, what other things do you have going on? Any new recent contacts?  \n",
            "\n",
            "This looks kindve like mono to me, which as the other med student said is caused by a virus. It could also be a pretty bad case of strep. If you have lymph node swelling it could be more indicative of one or the other. Regardless you're already on antibiotics so just finish the course. A pulse dose of steroids like prednisone would probably help with the swelling, but if you're uninsured you can do something like 600-800mg ibuprofen three times a day every six hours. In case it's mono ( I doubt you would do so feeling like that ) but be sure to avoid contact sports for fear of splenetic rupture ( aka skip tonight's roller derby game and get some rest :P ). ,Would have no problem throwing 4mg dexamethasone IV at these tonsils on a history of difficulty breathing.\n",
            "\n",
            "OP - do you have a fever? I may have missed that.,Stick with oral antis. They obviously won't touch EBV if that's what's up.\n",
            "\n",
            "The voice change and difficulty breathing is concerning - evidence of airway obstruction isn't something to be taken lightly. If you can get your hands on 8mg oral dexamethasone as a single dose that'd take the swelling down, resources permitting.,Yup, it was sarcasm :)  I'm Dutch and seeing all the posts of American people being so happy obamacare would be repealed by trump, but then getting heartbroken because ACA was the same thing, made me laugh to be honest. ,Which is it then? I hope you get better!\n",
            "\n",
            "Result  7\n",
            "Wait to see your PCP. That’s not an ED visit.,They’re diagnosing you over the phone which is just as valuable as Reddit. Lol. Strep doesn’t heal over night with medication and yes it is painful. Don’t waste an ER’s time on a sore throat. If you get a fever, go. If you don’t, wait to see your PCP.,Damn. Surely someone has recommend you get your tonsils out, right?,Well, you know your body best. If this feels like an ER visit then so be it. I would get a second opinion from a different doctor though. 1 time a year is miserable let alone 5 times a year! There is no “minimum time you have to have strep to get tonsils removed” rule. I would ask to be referred to an ENT and get them taken care of (if it works out with your personal life now of course.),Ha! Good luck!\n",
            "\n",
            "Result  8\n",
            "Get to an ED. This is serious those tonsils are swollen pretty good. ABC (Airway Breathing Circulation) \n",
            "First thing is your airway and that looks like it’s going to be occluded. \n",
            "\n",
            "Try to use Tyneol or an NSAID to help reduce pain and swelling. \n",
            "\n",
            "Result  9\n",
            "Photos aren't loading on imgur, but from the one I can see on Reddit, it looks pretty streppy. Have you started the amoxicillin? \n",
            "\n",
            "It may be the angle of the photo, but it looks kinda asymmetrical back there, which can be concerning for a paratonsillar abscess. If the difficulty swallowing gets worse, especially if it gets to the point where you're drooling, go to the ER. If you start having difficulty breathing, call 911 (or whatever equivalent in your country). \n",
            "\n",
            "Edit: fuso and strep are both responsive to amox. The concerns are sequelae, which can come from either. Again peritonsillar abscess, which I discussed above, but also watch for worsening fever, severe exhaustion, weakness, dizziness (all symptoms you probably already have to some extent, but if they get worse, go to the ER)\n",
            "\n",
            "Edit: thanks for the gold! Get better soon! ,The two primary causes for that asymmetry are peritonsillar abscess and peritonsillar cellulitis. The antibiotics would definitely resolve the cellulitis, not so much with an abscess. \n",
            "\n",
            "Generally, abscesses that pose a threat to your airway need to be drained. Based on what I can see from the picture, I don't think that's the case for you (disclaimer: I can't say for certain based on one picture). My original warnings still apply: ER if drooling or weird voice changes (google hot potato voice), 911 if trouble breathing. If, after the sore throat gets better, you still look asymmetrical back there, see your doctor for further eval. ,Looks alright, you should get better quick with the amox!\n",
            "\n",
            "Take care\n",
            "\n",
            "Result  10\n",
            "How high is your fever? Did the health clinic examine you before prescribing amoxicillin? \n",
            "\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "\n"
          ],
          "name": "stderr"
        }
      ]
    }
  ]
}